package com.homework8;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class client {
    public static void main(String[] args) throws IOException {
//        Socket socket = new Socket("192.168.2.237",6767);
        Socket socket = new Socket("192.168.2.166",8888);
        OutputStream os = socket.getOutputStream();
        Scanner sc = new Scanner(System.in);
        String info = null;
        do{
            if(info!=null && !info.isEmpty()){
                System.out.println("您输入的格式不正确!");
            }
            info = sc.nextLine();
        }while(info.indexOf("=")==-1 || info.split("=").length!=2);
        os.write(info.getBytes());
        InputStream is = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int len = is.read(bytes);
        System.out.println(new String(bytes, 0, len));
        socket.close();
    }
}
